<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="/xboard/css/common.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="/xboard/common/comment.js"></script>
<script type="text/javascript" src="/xboard/common/ajax.js"></script>
<script type="text/javascript">
	//input_id default value
	function fn_id(){	
		var temp = false;
		if(temp) return;
		document.cmtAddfrm.cmt_writer.value = "";
		document.getElementById("cmt_w").style.color="#000000";
		temp = true;
	}
	
	//input_pw default value
	function fn_pw(){	
		var temp = false;
		if(temp) return;
		document.cmtAddfrm.cmt_pass.value = "";
		document.getElementById("cmt_p").style.color="#000000";
		temp = true;
	}

	function fn_del(){
		var obj = document.cmtDelfrm;
		if(obj.cmt_pass.value != ''){
			obj.submit();
		}else{
			alert("비밀번호를 입력해주세요.");
		}
	}

	function fn_mod(){
		var obj = document.cmtUpdatefrm;
		if(obj.cmt_content.value != ''){
			if(obj.cmt_pass.value != ''){
				obj.submit();
			}else{
				alert("비밀번호를 입력해주세요.");
			}
		}else{
			alert("내용이 없습니다.");
		}
	}
	
</script>
<title>Xboard</title>
</head>
<body>
덧글
 	<table width="770" border="0" cellpadding="0" cellspacing="0" bgcolor="#efefef">
 		<tr>
 			<td height="10"></td>
 		</tr>
 		<tr>
 			<td align="center">
			 <s:iterator value="cmtList" status="stat">
				<s:if test="#stat.index >= 0">
					<div id="commentList<s:property value='#stat.index'/>">
							<table width="750" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff" style="padding-left: 5px;">
							<tr>
								<td width="700" height="25" valign="top" class="cmt_txt" style="padding-top: 10px;"><s:property value="cmt_writer"/><span style="margin-left: 8px;"><s:property value="cmt_regdate" /></span></td>
								<td width="70" class="cmt_txt" align="right" style="padding: 10px 5px 0 0;">
								<a href="javascript:modifyComment(<s:property value='cmt_no'/>,<s:property value='#stat.index'/>,<s:property value='cmt_bnum'/>)">수정</a> | 
								<a href="javascript:addDelElement(<s:property value='#stat.index'/>,<s:property value='cmt_no'/>,<s:property value='cmt_bnum'/>);">삭제</a>
								</td>
							</tr>
								<tr>
									<td width="770" height="54" colspan="2" style="padding:5px 0 10px 5px;"><s:property value="cmt_content" escape="false"/></td>
								</tr>
							<tr>
								<td height="1" colspan="2" bgcolor="#e9e9e9"></td>
							</tr>
						</table>
			   		</div>
			   		<div id="delView<s:property value='#stat.index'/>" style="display: none;"></div>
			   		<div id ="cmtUpdate<s:property value='#stat.index'/>" style="display: none;"></div>
				</s:if>
			 </s:iterator>
 			</td>
 		</tr>
 		<tr>
 			<td align="center" style="padding: 7px 0 7px 0;">
 				<div id = "cmtAdd">
					<form action="./cmtWrite.action" method="post" name="cmtAddfrm">
						<table width="750" border="0" cellpadding="0" cellspacing="0" bgcolor="#efefef">
							<tr>
								<td width="590" align="left"><textarea class="textarea2" name="cmt_content"></textarea></td>
								<td width="160" valign="bottom"">
									<input type="hidden" name="cmt_bnum" value="<s:property value="cmt_bnum" />">
									<input type="text" class="i_style cmt_input" name="cmt_writer" id="cmt_w" value="name" onfocus="fn_id();" style="color: #979797;"><br>
									<input type="password" class="i_style cmt_input" name="cmt_pass" id="cmt_p" value="pass" onfocus="fn_pw();" style="color: #979797;" maxlength="4">
									<input type="button" class="b_style cmt_btn" onclick="fn_add();" value="저장">
								</td>
							</tr>
						</table>
					</form>
				</div>
				<s:if test="%{totalPage > 1}">
					<div id="cmtPage">
						<s:if test="%{currentBlock > 1}">
							<a href="./cmtList.action?cmt_bnum=<s:property  value="cmt_bnum"/>&page=<s:property value="startPage-1"/>" class="r_sm" style="margin: 0 5px 0 0;">이전</a>
						</s:if>
						<s:elseif test="%{totalPage > endPage}">
							<span class="r_sm" style="margin: 0 5px 0 0;">이전</span>
						</s:elseif>
						<!-- number -->
						<c:forEach var="i" begin="${startPage}" end ="${endPage}">
	               	  		<c:choose>
	               	  			<c:when test="${i == currentPage}">
	               	  				<span style="margin: 0 1px 0 1px;color:#4d8800;">${i}</span>
	               	  			</c:when>
	               	  			<c:otherwise>
	               	  				<a href="./cmtList.action?cmt_bnum=<s:property  value="cmt_bnum"/>&page=${i}" style="margin: 0 1px 0 1px;">${i}</a>
	               	  			</c:otherwise>
	               	  		</c:choose>
	               	  	</c:forEach>
						<s:if test="%{totalPage > endPage}">
							<a href="./cmtList.action?cmt_bnum=<s:property  value="cmt_bnum"/>&page=<s:property value="endPage+1"/>" class="r_sm" style="margin: 0 0 0 5px;">다음</a>
						</s:if>
					    <s:elseif test="%{currentBlock > 1}">
	                    	<span class="r_sm" style="margin: 0 0 0 5px;">다음</span>
	                    </s:elseif>
					</div>
				</s:if>
 			</td>
 		</tr>
 	</table>
</body>
</html>

